home *** CD-ROM | disk | FTP | other *** search
/ CD ROM Paradise Collection 4 / CD ROM Paradise Collection 4 1995 Nov.iso / program / swagg_m.zip / GRAPHICS.SWG / 0054_Masked Images.pas < prev    next >
Pascal/Delphi Source File  |  1994-01-27  |  1KB  |  57 lines

  1. {
  2. >Try converting it to use pointers instead of accessing the array with
  3. >indexes, and use a pointer to video memory for direct plots
  4. >instead of using the putPixel routine. Also it's quicker to
  5. >check against 0 for the background than to check against 255.
  6.  
  7. I found a copy of "The Visible Computer: 8088" in my bookshelves and
  8. tried rewriting my assembly routines.  Here's what I finally got:
  9. }
  10.  
  11. procedure MaskPut(x,y: word; p: pointer); assembler;
  12. var
  13.  XX,YY: byte;
  14. asm
  15.         LES SI,p
  16.         MOV [XX],0
  17.         MOV [YY],0
  18.         MOV CX,256
  19.         XOR DX,DX
  20.         CLD
  21. @Loopit:SEGES LODSB
  22.         MOV DL,AL
  23.         PUSH ES
  24.         PUSH SI
  25.         CMP DL,255
  26.         JZ @Done
  27.         MOV AX,0A000h
  28.         MOV ES,AX
  29.         MOV AX,320
  30.         MOV BX,[Y]
  31.         ADD BL,[YY]
  32.         PUSH DX
  33.         MUL BX
  34.         POP DX
  35.         MOV BX,[X]
  36.         ADD BL,[XX]
  37.         ADD AX,BX
  38.         MOV SI,AX
  39.         MOV ES:[SI],DL
  40. @Done:  INC [XX]
  41.         CMP [XX],16
  42.         JNZ @Okay
  43.         MOV [XX],0
  44.         INC [YY]
  45. @Okay:  POP SI
  46.         POP ES
  47.         LOOP @Loopit
  48. end;
  49.  
  50. {
  51. It works fine.  I didn't notice much of a difference in speed though.  I
  52. tested it and I can plot about 1103 sprites/second in ASM and 828
  53. sprites/sec. with my original TP code.  Please keep in mind I'm not much
  54. of an assembly programmer. Can anyone help me optimize this code (into
  55. 286 would be good too). Thanx for your help!
  56. }
  57.